<template>
	<view class="follow-up">
		<block v-if="listData.length == 0">
			<view class="all_empty">
				<u-empty mode="data" text="跟进列表为空"></u-empty>
			</view>
		</block>
		<block v-else>
			<u-cell-group>
				<block v-for="(item, index) in listData" :key="index">
					<u-cell :title="item.type" :label="item.description">
						<view slot="value">
							<u--text text="已跟进" type="success" v-if="item.is_follow"></u--text>
							<u--text text="未跟进" type="error" v-else></u--text>
						</view>
						<view slot="label" class="desc">
							<text class="u-line-2">{{ item.description }}</text>
						</view>
					</u-cell>
				</block>
			</u-cell-group>
			<u-loadmore v-if="listData.length >= 10" :status="status" :loading-text="loadingText" :loadmore-text="loadmoreText" :nomore-text="nomoreText" />
		</block>
	</view>
</template>

<script>
export default {
	data() {
		return {
			queryForm: {
				detailId: 0,
				page: 1,
				limit: 10
			},
			listData: [],
			status: 'loadmore',
			loadingText: '努力加载中',
			loadmoreText: '轻轻上拉',
			nomoreText: '实在没有了'
		};
	},
	onLoad({ id }) {
		this.queryForm.detailId = id;
		this.getInfo();
	},
	onReachBottom() {
		if (this.status != 'nomore') {
			this.queryForm.page++;
			this.getInfo(true);
		}
	},
	methods: {
		getInfo(is_add = false) {
			let _this = this;
			this.status = 'loading';
			_this
				.$http('follow/getFollowListRecord', {
					..._this.queryForm
				})
				.then((res) => {
					if (res.code) {
						if (is_add) {
							this.listData = this.listData.concat(res.data.data);
						} else {
							this.listData = res.data.data;
						}
						if (res.data.total <= _this.listData.length) {
							this.status = 'nomore';
						} else {
							this.status = 'loadmore';
						}
					}
				});
		}
	}
};
</script>

<style lang="scss" scoped>
.desc {
	margin-top: 5px;
	font-size: 12px;
	color: #909193;
	line-height: 18px;
	margin-right: 20rpx;
}
</style>
